<style>
	/*ol contagem recursiva*/
	.contador ol { counter-reset: item }
	.contador li { display: block }
	.contador li:before {
		content: counters(item, ".") " "; counter-increment: item
	}
	/*fim da ol contagem recursiva*/
	.contador ol{
		list-style:decimal !important;
		padding: 10px;
	}
	.contador li{
		font-family: arial;
		font-weight: bold;
	}
	.contador li>p{
		font-weight: normal;
		padding: 10px;
		color: #0000FF;

	}
	.contador table{
		font-family: arial;
		font-weight: normal;
		/*			padding: 10px;*/
	}
	.contador table>caption{
		text-align:left;
	}
</style>
<div class="container">
	<?php if ( $tabelas): ?>
	<div class="contador">
		<ol>
			<li>Objetos de Banco de Dados
				<ol>
					<div class="contador">
						<?php foreach  ($tabelas as $dados): ?>
						<li><?php echo $dados['tabela']['nome'];?>
							<?php $constraints=0;?>
							<div class="lista fc-listagem-grupo descricao-tabela" >
								<h4 class="fc-listagem-titulo">Detalhe da tabela</h4>
								<div class="fc-listagem">
									<table summary="text" class="fc-dados-listagem table table-striped table-bordered table-condensed">
										<!--									<caption><?php echo $dados.tabela.nome;?>:<?php echo $dados['tabela']['descricao'];?></caption>-->
										<thead>
											<tr>
												<th class="ui-state-default">Tipo do campo</th>
												<th class="ui-state-default">Campo</th>
												<th class="ui-state-default">Tipo de dado</th>
												<th class="ui-state-default" title="Primary Key">PK</th>
												<th class="ui-state-default" title="Foreing Key">FK</th>
												<th class="ui-state-default" title="Unique Key">UK</th>
												<th class="ui-state-default" title="Not Null">NN</th>
												<th class="ui-state-default">Descrição</th>
											</tr>
										</thead>
										<tbody>
											<?php foreach ($dados['campos'] as $idx => $campo): ?>
											<tr title="<?php echo $campo['descricao'];?>" class="<?php echo $idx%2 ? 'fc-linha fc-linha1':'fc-linha fc-linha2';?>">
												<td class="campo1"><?php echo $campo['tipo_de_dado'];?></td>
												<td class="campo1"><?php echo $campo['campo'];?></td>
												<td class="campo1">
                                                                                                    <?php if ( $campo['tipo'] == 'character varying'): ?>
                                                                                                        varchar
                                                                                                    <?php else:?>
                                                                                                            <?php echo $campo['tipo'];?>
                                                                                                    <?php endif;?>
                                                                                                        
                                                                                                    <?php if ( $campo['tamanho']):?>
                                                                                                        (<?php echo $campo['tamanho'];?>)
                                                                                                    <?php endif;?>
                                                                                                </td>
												<td class="campo1" align='center' width='5px'><?php if ( $campo['campo_pk']):?>x<?php endif;?></td>
												<td class="campo1" align='center' width='5px'><?php if ( $campo['tabela_fk']):?>x<?php endif;?></td>
												<td class="campo1" align='center' width='5px'><?php if ( $campo['unique_key']):?>x<?php endif;?></td>
												<td class="campo1" align='center' width='5px'><?php if ( $campo['obrigatorio']):?>x<?php endif;?></td>
												<td class="campo1"><?php echo $campo['descricao'];?></td>
											</tr>
											<?php if ( $campo['tabela_fk']):?>
											<?php /*echo *php;?>$this->_tpl_vars['constraints'][$this->_tpl_vars['campo']['campo']]['campo']=$this->_tpl_vars['campo']['campo'];<?php echo /php*;?>
											<?php echo *php;?>$this->_tpl_vars['constraints'][$this->_tpl_vars['campo']['campo']]['constraint']=$this->_tpl_vars['campo']['constraint'];<?php echo /php*;?>
											<?php echo *php;?>$this->_tpl_vars['constraints'][$this->_tpl_vars['campo']['campo']]['esquema_fk']=$this->_tpl_vars['campo']['esquema_fk'];<?php echo /php*;?>
											<?php echo *php;?>$this->_tpl_vars['constraints'][$this->_tpl_vars['campo']['campo']]['tabela_fk']=$this->_tpl_vars['campo']['tabela_fk'];<?php echo /php*;?>
											<?php echo *php;?>$this->_tpl_vars['constraints'][$this->_tpl_vars['campo']['campo']]['campo_fk']=$this->_tpl_vars['campo']['campo_fk'];<?php echo /php*;?>
											<?php */endif;?>
											<?php endforeach;?>
									</table>
								</div>
								<?php if ( $constraints):?>
								<h4 class="fc-listagem-titulo">Chaves estrangeiras</h4>
								<table summary="text" class="fc-dados-listagem table table-striped table-bordered table-condensed">
									<!--									<caption>Chaves estrangeiras</caption>-->
									<thead>
										<tr>
											<th class="ui-state-default">Campo</th>
											<th class="ui-state-default">Nome da Restrição</th>
											<th class="ui-state-default">Tabela FK</th>
											<th class="ui-state-default">Campo FK</th>
										</tr>
									</thead>
									<tbody>
										<?php foreach  ($constraints as $idx => $constraint): ?>
										<tr title="<?php echo $campo['descricao'];?>" class="<?php echo $idx%2 ? 'fc-linha fc-linha1':'fc-linha fc-linha2';?>">
											<td class="campo1"><?php echo $constraint['campo'];?></td>
											<td class="campo1"><?php echo $constraint['constraint'];?></td>
											<td class="campo1"><?php echo $constraint['esquema_fk'];?>.<?php echo $constraint['tabela_fk'];?></td>
											<td class="campo1"><?php echo $constraint['campo_fk'];?></td>
										</tr>
										<?php endforeach;?>
								</table>
								<?php endif;?>
								<?php if ( $dados['restricoes']):?>
								<table summary="text" class="tabela0 ui-widget-content ui-corner-all table table-striped table-bordered table-condensed" style="width:100%;" border='1'>
									<caption>Outras restrições</caption>
									<thead>
										<tr>
											<th class="ui-state-default">Nome da Restrição</th>
											<th class="ui-state-default">Condição</th>
											<th class="ui-state-default">Descrição</th>
										</tr>
									</thead>
									<tbody>
										<?php foreach ($dados['restricoes'] as $idx => $restricao):?>
										<tr>
											<td class="campo1"><?php echo $restricao['nome'];?></td>
											<td class="campo1"><?php echo $restricao['condicao'];?></td>
											<td class="campo1"><?php echo $restricao['descricao'];?></td>
										</tr>
										<?php endforeach;?>
								</table>
								<?php endif;?>
							</div>
							<br/>
						</li>
						<?php endforeach;?>
					</div>
				</ol>
			</li>
		</ol>
	</div>
	<?php else: ?>
	<form name="formulario" method="post" action="<?php echo $action;?>" class="contador form form-horizontal well well-small">
		<div>
			<h4 class="ui-state-default ui-corner-all"><?php echo $tituloEspecifico;?></h4>
			<hr/>
			<div>
				<div class="tabela2">
					<div class="control-group">
						<label class="control-label" >Tipo:</label>
						<div class="controls"><?php echo $tipo;?></div>
					</div>
					<div class="control-group">
						<label class="control-label" >Servidor:</label>
						<div class="controls"><?php echo $servidor;?></div>
					</div>
					<div class="control-group">
						<label class="control-label" >Porta:</label>
						<div class="controls"><?php echo $porta;?></div>
					</div>
					<div class="control-group">
						<label class="control-label" >Banco:</label>
						<div class="controls"><?php echo $banco;?></div>
					</div>
					<div class="control-group">
						<label class="control-label" >Usuário:</label>
						<div class="controls"><?php echo $usuario;?></div>
					</div>
					<div class="control-group">
						<label class="control-label" >Senha:</label>
						<div class="controls"><?php echo $senha;?></div>
					</div>
				</div>
			</div>
		</div>
	</form>
	<div id='menu_corpo'>
		<?php echo $menuPrograma;?>
	</div>
	<?php endif;?>
</div>